package com.xbang.attendance.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.xbang.attendance.entity.system.Region;
import com.xbang.attendance.service.RegionService;
import com.xbang.core.service.impl.BaseServiceImpl;

import enumeration.RegionType;

/**
 * @author huawei
 * @email alonelaval@gmail.com
 */
@Service("regionService")
public class RegionServiceImpl extends BaseServiceImpl implements RegionService{

	@Override
	public List<Region> getAKZRegion() throws Exception {
		return getRegions(RegionType.AKZ);
	}

	private List<Region> getRegions(RegionType type)throws Exception{
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append("FROM Region region where region.regionType = ?");
		return genericDaoSupport.getHibernateTemplate().find(sBuilder.toString(),new Object[]{type}) ;
	}
	@Override
	public List<Region> getSGMRegion() throws Exception {
		return getRegions(RegionType.SGM);
	}

}

